      <template>
          <section>
              <div>
            <el-table :data="statusQuerry" style="width: 100%">
                <el-table-column type="index" align="center" label="编号"></el-table-column>
                <el-table-column prop="name"align="center" label="商家名称"></el-table-column>
                <el-table-column prop="state"align="center" label="商家状态" :formatter="formatState"></el-table-column>
                <el-table-column prop="tel" align="center" label="联系电话"></el-table-column>
                <el-table-column prop="registerTime" align="center" label="申请时间"></el-table-column>
                <el-table-column prop="address" align="center" label="商铺地址"></el-table-column>
                <el-table-column label="操作" width="150" >
                    <template slot-scope="scope">
                        <el-button @click="handleClick(scope.row)" type="text" size="mini">审阅</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <!--增加和修改模态框-->
                  <el-dialog title="审核" :visible.sync="dialogVisible"  width="30%">
                      <!--修改弹窗-->
                      <el-form v-model="shopForm"  label-width="100px">
                          <!--<h3>商家信息</h3>
                          <el-form-item label="商家名称" prop="username">
                              <el-input v-model="shopForm.name"></el-input>
                          </el-form-item>
                          <el-form-item label="电话" prop="tel">
                              <el-input v-model="shopForm.tel"></el-input>
                          </el-form-item>
                          <el-form-item label="地址" prop="address">
                              <el-input v-model="shopForm.address"></el-input>
                          </el-form-item>-->
                          <!--<el-form-item label="审核状态" prop="state">
                              <el-input v-model="shopForm.state"></el-input>
                          </el-form-item>-->
                          <!--<el-form-item label="店铺Logo" prop="logo">
                              <el-input v-model="shopForm.logo"></el-input>
                          </el-form-item>-->
                          <!--<h3>管理员信息</h3>
                          <el-form-item prop="username" label="账号">
                              <el-input type="text" v-model="shopForm.admin.username" ></el-input>
                          </el-form-item>
                          <el-form-item prop="tel" label="手机号码">
                              <el-input type="text" v-model="shopForm.admin.phone"></el-input>
                          </el-form-item>
                          <el-form-item prop="email" label="电子邮件">
                              <el-input type="text" v-model="shopForm.admin.email"></el-input>
                          </el-form-item>
                          <el-form-item prop="password" label="密码">
                              <el-input type="password" v-model="shopForm.admin.password"></el-input>
                          </el-form-item>-->
                          <el-form-item label="审阅状态" prop="state">
                              <el-radio-group v-model="shopForm.state">
                                  <el-radio class="radio" :label=1>审核通过</el-radio>
                                  <el-radio class="radio" :label=0>待审核</el-radio>
                                  <el-radio class="radio" :label=-1>驳回</el-radio>
                              </el-radio-group>
                          </el-form-item>
                          <el-form-item label="审核理由">
                              <el-input type="textarea" placeholder="请输入理由"v-model="shopForm.reson"></el-input>
                          </el-form-item>
                      </el-form>
                <span slot="footer" class="dialog-footer">
                    <el-button @click="adoptSubmit">确定</el-button>
                 </span>
            </el-dialog>
              </div>
    </section>
</template>

<script>
    import {message} from "../../../Pethome_front/plugins/axios";

    export default {
        data() {
            return {
                statusQuerry:[],
                dialogVisible:false,
                shopForm:{
                    name: '',
                    tel: '',
                    address: '',
                    logo:'',
                    admin:{
                        username:'',
                        tel:'',
                        phone:'',
                        email:'',
                        password:'',
                    },
                    state:"",
                    reson:"",
                    date:"",
                    shop:""
                },
            }
        },
        methods:{
            loadShopMessage(){
                let param = {
                    shop_id:27
                }
                this.$http.patch("http://localhost/status/loadShopMessage",param).then((result=>{
                    console.debug(result);
                    this.statusQuerry = result.data.shop;
                }))
            },
            formatState(row,column){
                return  row.state==1?"审核完成":(row.state==0?"待审核":"驳回");
            },
            //审阅
            handleClick(row){
                this.dialogVisible=true;
                console.debug("---------------------",row)
                for(var t in row){
                    this.shopForm[t] = row[t];
                }
            },
            handleEdit(index,row){
                this.dialogVisible=true;
            },
            //确定事件
            adoptSubmit(){
                for (var s in this.shopForm.status){
                    this.shopForm.status[s]="";
                }
                console.debug("===========",this.shopForm)
                let status={
                    reson:this.shopForm.reson,
                    states:this.shopForm.state,
                    shop:this.shopForm,
                }
                //console.debug("==================",JSON.stringify(this.shopForm.status))
                this.dialogVisible=false;
                this.$http.post("http://localhost/status/adopt",status).then((result=>{
                    if(result.data.success){
                        message:"成功";
                    }else{
                        this.$message.error(result.data.msg);
                    }
                    this.loadShopMessage();
                }));

            },
            /*//驳回
            rejectSubmit(){
                let param=this.shopForm;
                this.dialogVisible=false;
                this.$http.put("http://localhost/status/reject",param).then((result=>{

                }));
            }*/

        },

        mounted(){
            this.loadShopMessage();
        }
    }
</script>